<template>
    <div class="r_main">
        <div class="tabIn">
            <div class="tab">
                社区严选
            </div>
            <div class="sqin">
                <div class="btn2" @click="goPage">
                    申请严选
                </div>
                <div class="search">
                    <input type="text" placeholder="请输入内容" placeholder-class="pla" v-model="keyword"
                        @keyup.enter="goSearch">
                    <img src="@/assets/img/search.svg" alt="" @click="goSearch()" style="cursor: pointer;">
                </div>
            </div>
        </div>
        <div class="form_con">
            <div class="outer" v-if="!$store.getters.isMobile">
                <el-table border :data="list" style="width: 100%">
                    <el-table-column prop="act_name" label="严选主题" width="180">
                        <template slot-scope="scope">

                            <p style="color: #1068E7;">
                                {{ scope.row.act_name }}
                            </p>
                        </template>
                    </el-table-column>
                    <el-table-column prop="type" label="活动时间" align="center" width="180">
                        <template slot-scope="scope">
                            <p>
                                {{ scope.row.start_time }}开始
                            </p>
                            <p>
                                {{ scope.row.end_time }}结束
                            </p>
                        </template>
                    </el-table-column>
                    <el-table-column prop="col_name" align="center" label="参选专栏名称">
                    </el-table-column>
                    <el-table-column prop="price" align="center" label="管理费">
                    </el-table-column>
                    <el-table-column prop="pay_time" align="center" label="支付时间">
                    </el-table-column>
                    <el-table-column prop="ver_name" align="center" label="审核情况">
                    </el-table-column>
                    <el-table-column prop="tk_time" align="center" label="退款时间">
                    </el-table-column>
                    <el-table-column prop="author" align="center" label="严选数据">
                        <template slot-scope="scope">
                            <div class="acs">
                                <div class="action">
                                    <div>
                                        浏览<span>{{ scope.row.nums.views }}</span>
                                    </div>
                                    <div>
                                        文库<span>{{ scope.row.nums.arts }}</span>
                                    </div>
                                    <div>
                                        成交次数<span>{{ scope.row.nums.orders }}</span>
                                    </div>
                                </div>
                                <div class="action">
                                    <div>
                                        点赞<span>{{ scope.row.nums.likes }}</span>
                                    </div>
                                    <div>
                                        评论<span>{{ scope.row.nums.coms }}</span>
                                    </div>
                                    <div>
                                        成交金额<span>{{ scope.row.nums.total }}</span>
                                    </div>
                                </div>
                            </div>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
            <div class="outer_mob" v-else>
                <div class="info" v-for="item in list" :key="item.id">
                    <div>
                        <span>严选主题</span>
                        <span>{{ item.act_name }}</span>
                    </div>
                    <div>
                        <span>活动开始时间</span>
                        <span> {{item.start_time }}</span>
                    </div>
                    <div>
                        <span>活动结束时间</span>
                        <span> {{ item.end_time }}</span>
                    </div>
                    <div>
                        <span>参选专栏名称</span>
                        <span>{{ item.col_name }}</span>
                    </div>
                    <div>
                        <span>管理费</span>
                        <span>{{ item.price }}</span>
                    </div>
                    <div>
                        <span>支付时间</span>
                        <span>{{ item.pay_time }}</span>
                    </div>
                    <div>
                        <span>审核情况</span>
                        <span>{{ item.ver_name }}</span>
                    </div>
                    <div>
                        <span>退款时间</span>
                        <span>{{ item.tk_time }}</span>
                    </div>
                    <div>
                        <span>严选数据</span>
                        <div class="acs">
                                <div class="action">
                                    <div>
                                        浏览<span>{{ item.nums.views }}</span>
                                    </div>
                                    <div>
                                        文库<span>{{ item.nums.arts }}</span>
                                    </div>
                                    <div>
                                        成交次数<span>{{ item.nums.orders }}</span>
                                    </div>
                                </div>
                                <div class="action">
                                    <div>
                                        点赞<span>{{ item.nums.likes }}</span>
                                    </div>
                                    <div>
                                        评论<span>{{ item.nums.coms }}</span>
                                    </div>
                                    <div>
                                        成交金额<span>{{ item.nums.total }}</span>
                                    </div>
                                </div>
                            </div>
                    </div>

                </div>
                <div v-if="list.length == 0">
                    <el-empty description="没有内容了"></el-empty>
                </div>
            </div>
        </div>
    </div>

</template>
<script>
import t1 from "@/assets/img/t1.png"
export default {
    data() {
        return {
            list: [],
            totalPage: 1,
            pageNum: 1,
            loading: false,
            keyword: '',
        }
    },
    computed: {
        path() {
            return this.$route.path
        }
    },
    mounted() {
        window.addEventListener('scroll', this.handleScroll); // 监听滚动事件
        this.getList()

    },
    beforeDestroy() {
        window.removeEventListener('scroll', this.handleScroll); // 移除监听
    },

    methods: {
        goSearch() {
            this.pageNum = 1
            this.list = []
            this.getList()
        },
        getList() {
            this.loading = true

            let params = {
                id: this.cid,
                keyword: this.keyword
            }

            this.$api.checkActi(params).then(res => {
                if (res.data.code == 1) {
                    this.totalPage = res.data.data.last_page
                    this.list = this.list.concat(res.data.data.data);
                    this.loading = false
                }

            })
        },
        goPage() {
            this.$router.push('/promotion/articleDetail')
        },
        confirm(item) {
            console.log(item);

        },
        load() {
            console.log("处理触底");
            var page = this.pageNum

            //如果请求未结束就返回不连续请求
            if (this.loading) {
                return
            }
            //数据请求完成无更多数据时
            if (page >= this.totalPage) {
                return false;
            }
            page = parseInt(page) + 1
            this.pageNum = page
            this.getList()
        },
        onsubmit() {
            console.log(this.form);

        },
        handleScroll() {
            const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
            const windowHeight = window.innerHeight;
            const scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
            // 判断是否滚动到底部
            if (scrollTop + windowHeight >= scrollHeight - 20) {
                this.load()
            }
        },
    }
}
</script>
<style lang="scss" scoped>
.r_main {
    width: 100%;

    .user {
        width: 100%;
        height: 200px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        position: relative;
        padding: 0 30px;
        overflow: hidden;
        background: linear-gradient(to right, rgba(0, 0, 0, 1), rgba(0, 0, 0, 0));

        .bgg {
            position: absolute;
            width: 100%;
            height: auto;
            z-index: -1;

        }

        .left {
            display: flex;
            color: #fff;
            align-items: center;

            .avatar {
                width: 150px;
                height: 150px;
                margin-right: 27px;
                flex-shrink: 0;
                border-radius: 50%;
                overflow: hidden;

                img {
                    object-fit: cover;
                    width: 100%;
                    height: 100%;
                }
            }

            .info {
                .nane {
                    font-weight: bold;
                    font-size: 30px;
                    color: #FFFFFF;
                    margin-bottom: 13px;
                }

                .data {
                    display: flex;
                    align-items: center;
                    margin-bottom: 13px;

                    .line {
                        height: 18px;
                        display: block;
                        width: 2px;
                        background-color: #fff;
                        margin: 0 18px;
                    }

                    >div {
                        font-weight: 400;
                        font-size: 18px;
                        color: #999999;

                        >span {
                            color: #FFFFFF;
                        }
                    }
                }

                .address {
                    display: flex;
                    align-items: center;
                    margin-bottom: 10px;
                    font-weight: 400;
                    font-size: 16px;
                    color: #999999;

                    .line {
                        margin: 0 18px;
                        display: block;
                        height: 16px;
                        width: 2px;
                        background-color: #999;
                    }
                }

                .sign {
                    font-weight: 400;
                    font-size: 16px;
                    color: #FFFFFF;
                }
            }
        }

        .right {
            height: 100%;
            padding: 28px 0 38px;
            font-weight: 400;
            display: flex;
            justify-content: space-between;
            align-items: flex-end;
            flex-direction: column;
            font-size: 20px;
            color: #FFFFFF;

            .share {
                cursor: pointer;
                display: flex;
                align-items: center;
                justify-content: center;

                img {
                    width: 28px;
                    height: auto;
                    margin-left: 11px;
                }
            }

            .btn {
                display: flex;
                align-items: center;
                justify-content: center;

                button {
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    width: 120px;
                    height: 48px;
                    background: #F98951;
                    border-radius: 24px;
                    opacity: 0.9;
                    margin-left: 26px;
                    font-weight: 400;
                    font-size: 20px;
                    color: #FFFFFF;
                    border: none;

                    &:nth-child(2) {
                        background: #1068E7;
                    }
                }
            }
        }
    }

    .tabIn {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 23px 0;
        background-color: #E5E5E5;
        position: sticky;
        top: 99px;
        z-index: 99;
        padding: 0 23px;
        height: 60px;

        // border-top: 0.05rem solid #E8E8E8;
        .tab {
            font-weight: bold;
            font-size: 24px;
            color: #1068E7;
        }

        .sqin {
            display: flex;
            align-items: center;

            .btn2 {
                cursor: pointer;
                font-weight: 400;
                font-size: 14px;
                color: #1068E7;
                background: #FFFFFF;
                border-radius: 4px;
                border: 1px solid #1068E7;
                padding: 8px 10px;
            }

            .search {
                height: 48px;
                background: #F6F6F6;
                border-radius: 24px;
                position: relative;
                margin-left: 68px;
                width: 280px;
                display: flex;
                align-items: center;

                img {
                    width: 1.2rem;
                    height: 1.2rem;
                    position: absolute;
                    top: calc(50% - 0.6rem);
                    right: 1.2rem;
                }

                input {
                    width: 18.75rem;
                    height: 2.5rem;
                    outline: none;
                    background: #F6F6F6;
                    border-radius: 1.25rem;
                    padding: 0 3rem 0 1.2rem;
                    box-sizing: border-box;
                    font-size: 0.83rem;
                    border: none;
                    border: 1px solid #F6F6F6;

                    &:focus {
                        border: 1px solid #1068E7;
                    }
                }

                .pla {
                    font-weight: 400;
                    font-size: 0.83rem;
                    color: #666666;
                }
            }
        }


    }

    .form_con {
        min-height: 500px;
        // overflow-y: auto;
    }
}

.outer {
    margin-top: 30px;
    display: flex;
    align-items: flex-start;
    padding-bottom: 20px;

    ::v-deep .el-table th.el-table__cell {
        background-color: #E7F1FE;
    }

    .y1 {
        width: 100%;
        display: flex;
        flex-wrap: wrap;

        >div {
            width: calc(50% - 12.5px);

            &:nth-child(2n) {
                margin-left: 25px;
            }
        }
    }

    .list {
        display: flex;
        align-items: flex-start;
        flex-wrap: wrap;
        width: 100%;

        .title {
            display: flex;
            align-items: center;
            font-weight: 400;
            font-size: 18px;
            color: #000000;

            img {
                width: 16px;
                height: auto;
                margin-right: 16px;
            }

            .name {
                width: 700px;
            }
        }

        .set {
            display: flex;
            align-items: center;
            justify-content: space-between;
            flex: 1;

            .data {
                font-size: 16px;
                color: #999;
                display: flex;
                align-items: center;

                >span {
                    display: inline-block;
                    flex-shrink: 0;
                }

                .dz {
                    margin-right: 15px;
                    width: 100px;
                    text-align: center;
                }

                .line {
                    width: 2px;
                    height: 15px;
                    background-color: #999;
                }

                .nums {
                    width: 120px;
                    text-align: center;
                }

                .nickname {
                    margin-left: 15px;
                }
            }

            .btn {
                display: flex;

                .price {
                    font-size: 20px;
                    color: #D31B23;
                    margin-right: 50px;
                }

                button {
                    width: 80px;
                    height: 30px;
                    background-color: #1169E5;
                    border: none;
                    border-radius: 5px;
                    color: #fff;
                }
            }
        }
    }
}

.acs {
    display: flex;
    justify-content: center;
}

.action {
    display: inline-flex;
    flex-direction: column;
    white-space: nowrap;
    font-size: 12px;

    span {
        display: inline-block;
        color: rgb(16, 104, 231);
    }

    >div {
        border-right: 1px solid #4d4d4d;
        margin-bottom: 0.2rem;
        padding-right: 10px;
        margin-right: 10px;
        text-align: right;
    }

    &:nth-child(2) {
        >div {
            text-align: left;
            border: none;
            padding-right: 0;
            margin-right: 0px;
        }
    }
}

@media screen and (max-width:768px) {

    .r_main .tabIn {
        height: 40px;
        padding: 0 20px;

        .tab {
            font-size: 15px;
        }

        .sqin {
            .btn2 {
                font-size: 12px;
                width: 70px;
                height: 25px;
                line-height: 20px;
                text-align: center;
                padding: 2px 5px;
            }

            .search {
                width: auto;

                input {
                    width: 150px;
                    height: 30px;
                    font-size: 12px;
                    padding-right: 17px;
                }

                img {
                    width: 15px;
                    height: 15px;
                    top: calc(50% - 7px);
                }
            }
        }
    }

    .outer_mob {
        padding: 10px 20px;

        .info {
            border: 1px solid #ccc;
            border-radius: 10px;
            padding: 10px;
            margin-bottom: 10px;

            >div {
                display: flex;
                align-items: center;
                flex-wrap: wrap;
                margin-bottom: 5px;

                &:last-child {
                    margin: 0;
                }

                >span {
                    display: inline-block;
                    font-size: 13px;

                    &:first-child {
                        font-size: 14px;
                        font-weight: bold;
                        width:100px;
                    }
                }
                .acs{
                    padding:  5px 10px;
                    border: 1px solid #ccc;
                    border-radius: 5px;
                    .action{
                        font-size: 12px;
                        margin-right: 20px;
                        >div{
                            text-align: left;
                            border: none;
                        }
                    }
                }
            }

            .btm {
                font-size: 12px;

                >div {
                    width: 100%;
                    display: flex;
                    justify-content: center;
                    margin-top: 20px;

                    >div {
                        border: 1px solid #ccc;
                        padding: 5px 10px;
                    }
                }
            }

            ::v-deep .el-button--mini {
                font-size: 12px;
                padding: 5px 10px;
            }

        }
    }
}
</style>